import {request} from "umi";
import ServiceEnvs from "@/services/ServiceEnvs";
import {getUserInfo} from "@/utils/format";

const baseUrl = ServiceEnvs.baseUrl
export const AllSchools = () => {
  const userInfo = getUserInfo()

  return request(baseUrl+'/api/alluniv', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Authorization': userInfo.token
    },
  })
}

export const AllSubjects = () => {
  const userInfo = getUserInfo()

  return request(baseUrl+'/api/gov-query-school-disc-eval', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Authorization': userInfo.token
    },
  })
}

// 修改密码
export const ChangePasswordAPI = (api: string, username: string, oldpassword: string, newpassword: string) => {
  const userInfo = getUserInfo()
  const queryString = new URLSearchParams({username, oldpassword, newpassword}).toString()
  return request(baseUrl+api, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      'Authorization': userInfo.token
    },
    data: queryString,
  })
}
